package com.yanfei.zero;

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.yanfei.zero.domain.user.model.perms.AuthInterceptor;


@SpringBootApplication
@EnableCaching
@EnableDiscoveryClient
@EnableFeignClients
public class ZeroApplication implements WebMvcConfigurer {

	public static void main(String[] args) {
		SpringApplication.run(ZeroApplication.class, args);
	}

	
    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 拦截器，校验规则为 StpUtil.checkLogin() 登录校验。
        registry.addInterceptor(authInterceptor());
        
    }
    
    @Bean
    public AuthInterceptor authInterceptor() {
    	return new AuthInterceptor();
    }
    
    @Bean
    public MessageConverter messageConverter() {
    	return new Jackson2JsonMessageConverter();
    }
    
}
